package com.kronos.gui;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;

public class Label extends Drawable {

	private BitmapFont font;
	private String str;

	private int mouseX = 0, mouseY = 0;

	private Vector3 vec;

	private OrthographicCamera cam;

	public Label(String str, int x, int y, OrthographicCamera cam) {
		this.x = x;
		this.y = y;
		this.str = str;

		this.cam = cam;
		vec = new Vector3();

		font = new BitmapFont();
	}

	private boolean mouseHovering() {
		float mouseX = this.mouseX;
		float mouseY = this.mouseY;

		vec.set(mouseX, mouseY, 0);
		cam.unproject(vec);

		// (0,0) Starts at top left corner
		return ((vec.x >= x && vec.x <= x + font.getBounds(str).width) && (vec.y >= y
				- font.getBounds(str).height && vec.y <= y));
	}

	public void setString(String str) {
		this.str = str;
	}

	@Override
	public void update() {
		if (mouseHovering()) {
			font.setColor(Color.ORANGE);
		} else {
			font.setColor(Color.WHITE);
		}
	}

	@Override
	public void render(SpriteBatch sb) { 
		if (str != null) {
			font.draw(sb, str, x, y);
		} 
	}

	@Override
	public boolean keyDown(int keycode) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyUp(int keycode) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyTyped(char character) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDown(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchUp(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDragged(int screenX, int screenY, int pointer) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean mouseMoved(int screenX, int screenY) {
		this.mouseX = screenX;
		this.mouseY = screenY;
		return false;
	}

	@Override
	public boolean scrolled(int amount) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDown(float x, float y, int pointer, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean tap(float x, float y, int count, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean longPress(float x, float y) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean fling(float velocityX, float velocityY, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean pan(float x, float y, float deltaX, float deltaY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean panStop(float x, float y, int pointer, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean zoom(float initialDistance, float distance) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2,
			Vector2 pointer1, Vector2 pointer2) {
		// TODO Auto-generated method stub
		return false;
	}
}
